export function useAsideToggle() {
    const threshold = 1440
    const target = document.documentElement
    const collapsed = ref(true)
    onMounted(() => {
        addListener(target, resizeHandler)
        resizeHandler(target)
    })
    onUnmounted(() => {
        removeListener(target, resizeHandler)
    })
    function resizeHandler(el: HTMLElement) {
        collapsed.value = el.getBoundingClientRect().width < threshold
    }
    function handleToggle() {
        collapsed.value  = !collapsed.value
    }
    return {
        collapsed,
        handleToggle
    }
}